<template>
<div class="home">
  <div class="header">
    <van-icon name="location" @click="place" /><span class="site">{{site || ''}}</span>
    <van-search v-model="value" placeholder="请输入疾病/药品/症状/医生/检查" @click="$router.push('/search')" />
  </div>
  <div class="main">
    <div class="slideshow">
      <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
        <van-swipe-item><img src="@/assets/img/img_03.jpg" /></van-swipe-item>
        <van-swipe-item><img src="@/assets/img/img_03.jpg" /></van-swipe-item>
      </van-swipe>
    </div>
    <div class="f1">
      <div class="f1-item">
        <img src="@/assets/img/home_find_doc.jpg" alt />
        <div class="right">
          <h6>快速提问</h6>
          <p style="fontSize:40px">智能匹配医生</p>
        </div>
      </div>
      <div class="f1-item">
        <img src="@/assets/img/home_find_doc.jpg" alt />
        <div class="right">
          <h6>找医生</h6>
          <p style="fontSize:40px">全国60万+名医</p>
        </div>
      </div>
    </div>
    <!-- 找医院 -->
    <div class="f2">
      <div class="f2-item">
        <img src="@/assets/img/img_07.jpg" alt />
        <span>找医院</span>
      </div>
      <div class="f2-item">
        <img src="@/assets/img/img_09.jpg" alt />
        <span>名院专家</span>
      </div>
      <div class="f2-item">
        <img src="@/assets/img/img_11.jpg" alt />
        <span>快速购药</span>
      </div>
      <div class="f2-item">
        <img src="@/assets/img/img_13.jpg" alt />
        <span>图文急诊</span>
      </div>
      <div class="f2-item">
        <img src="@/assets/img/img_15.jpg" alt />
        <span>快捷电话</span>
      </div>
    </div>
    <!-- 医特色科室 -->
    <div class="f3">
      <p class="title">
        <span>特色科室</span>
        <span class="more">查看更多></span>
      </p>
      <div class="f3-item">
        <div class="left">
          <img src="@/assets/img/1_03.jpg" alt />
          <img src="@/assets/img/1_09.jpg" alt />
        </div>
        <div class="right">
          <img src="@/assets/img/1_05.jpg" alt />
          <img src="@/assets/img/1_07.jpg" alt />
          <img src="@/assets/img/1_10.jpg" alt />
        </div>
      </div>
      <!-- 医生话题 -->
      <div class="f4">
        <div class="f4-title">
          <span>医生话题</span>
          <span>查看全部></span>
        </div>
        <div class="f4_list">
          <ul v-for="(item,index) in  doctorList" :key="index">
            <li class="f4_list_one">【{{item.type}}】{{item.title}}</li>
            <li class="f4_list_two">
              <p>{{item.author}} {{item.address}}</p>
              <p>阅读 {{item.read}} 点赞{{item.like}}</p>
            </li>
          </ul>
        </div>
      </div>
      <!-- 患者好评 -->
      <div class="f5">
        <div class="f5-title">
          <span>患者好评</span>
          <span>换一换</span>
        </div>
        <div class="f5_list">
          <ul>
            <li v-for="(item,index) in doctortalkList" :key="index">
              <p class="title">
                <span>
                  <img :src="item.avatar" alt />
                  <span class="username">{{item.name.slice(0,1)}}****{{item.name.slice(-4)}}</span>
                  <span class="msg">给{{item.to}}医生送心意</span>
                </span>
                <span class="good">好评</span>
              </p>
              <p class="text">{{item.text}}</p>
            </li>
          </ul>
        </div>
      </div>
      <!--服务保障-->
      <div class="f6">
        <div class="f6-top">
          <h2>服务保障</h2>
          <p class="f6_list">
            <span>严格审核</span>
            <span>专业问诊</span>
            <span>放心药品</span>
          </p>
          <span>&gt;</span>
        </div>
        <div class="f6-btm">
          <p>
            累计注册
            <span>{{doctorNum}}</span>位医生
          </p>
          <p>
            共服务
            <span>{{userNum}}</span>位用户
          </p>
        </div>
      </div>
    </div>
  </div>
</div>
</template>

<script>
import {
  Dialog
} from 'vant';
export default {
  data() {
    return {
      site: sessionStorage.getItem('place'),
      value: "",
      doctorNum: 629950,
      userNum: 137652914,
      doctorList: [ // 医生话题
        {
          type: '科普',
          title: '地方和今后今日？',
          address: '哈尔滨大学第一医院',
          like: 100,
          read: 200,
          author: '张淑红'
        },
        {
          type: '科普',
          title: '地方和今后今日？',
          address: '哈尔滨大学第一医院',
          like: 100,
          read: 200,
          author: '张淑红'
        },
        {
          type: '科普',
          title: '地方和今后今日？',
          address: '哈尔滨大学第一医院',
          like: 100,
          read: 200,
          author: '张淑红'
        }
      ],
      doctortalkList: [{
          avatar: require('@/assets/img/img.png'),
          name: '我是77431313213232',
          to: '张媛',
          text: '医生很有善，急病人之所急，不仅业务能力强，而且还能设身处地为病人着想！真正的好医生！'
        },
        {
          avatar: require('@/assets/img/img.png'),
          name: '我是7743131322143241',
          to: '张媛',
          text: '医生很有善，急病人之所急，不仅业务能力强，而且还能设身处地为病人着想！真正的好医生！'
        },
        {
          avatar: require('@/assets/img/img.png'),
          name: '我是774313132121324',
          to: '张媛',
          text: '医生很有善，急病人之所急，不仅业务能力强，而且还能设身处地为病人着想！真正的好医生！'
        },
        {
          avatar: require('@/assets/img/img.png'),
          name: '我是7743131321',
          to: '张媛',
          text: '医生很有善，急病人之所急，不仅业务能力强，而且还能设身处地为病人着想！真正的好医生！'
        }
      ]
    }
  },
  methods: {
    place() {
      if (!sessionStorage.getItem('place')) {
        Dialog.confirm({
          title: '提示',
          message: '是否获取当前位置'
        }).then(() => {
          this.getPlace()
        }).catch(() => {})
      }
    },
    getPlace() {
      AMap.plugin('AMap.CitySearch', function () {
        var citySearch = new AMap.CitySearch()
        citySearch.getLocalCity(function (status, result) {
          if (status === 'complete' && result.info === 'OK') {
            console.log(result.province)
            // this.$toast.success('定位成功')
            sessionStorage.setItem('place', result.province)
            location.reload()
          }
        })
      })
    }
  },
  created() {
    this.place()
  },
}
</script>

<style lang="scss" scoped>
.home {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 10px;
}

.header {
  width: 100%;
  height: 60px;
  align-items: center;
  display: flex;

  .site {
    font-weight: 200;
    font-size: 14px;
  }

  .van-search {
    flex: 1;
  }
}

.main {
  width: 100%;
  height: 100%;
  overflow: auto;

  .my-swipe,
  .van-swipe-item {
    width: 100%;

    img {
      width: 100%;
    }
  }

  .f1 {
    width: 100%;
    display: flex;
    justify-content: space-between;
    height: 80px;
    align-items: center;

    .f1-item {
      display: flex;
      flex: 1;
      box-shadow: 0px 0px 3px 3px #fbfbfb;

      img {
        width: 50px;
        height: 50px;
      }

      .right {
        margin-left: 10px;

        h5 {
          font-size: 20px;
          font-weight: 500;
        }

        p {
          color: #b8b8b8;
          margin-top: 10px;
          font-size: 16px;
        }
      }
    }
  }

  .f2 {
    display: flex;
    height: 80px;
    align-items: center;
    justify-content: space-between;

    .f2-item {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      color: #b8b8b8;

      img {
        width: 30px;
        height: 30px;
        margin-bottom: 5px;
      }

      span {
        font-size: 12px;
        margin-top: 6px;
      }
    }

  }

  .f3 {
    width: 100%;

    .title {
      display: flex;
      justify-content: space-between;
      margin: 20px 0;

      span:nth-child(1) {
        font-size: 18px;
      }

      span:nth-child(2) {
        font-size: 14px;
        color: #b7b7b7;
      }
    }

    .f3-item {
      display: flex;
      justify-content: space-between;

      .left {
        width: 48%;
        height: 270px;
        display: flex;
        flex-direction: column;

        img:nth-child(1) {
          height: 70%;
        }

        img:nth-child(2) {
          height: 28%;
          margin-top: 2%;
        }
      }

      .right {
        width: 50%;
        height: 270px;

        img {
          width: 100%;
          height: 32%;
          margin-top: 1%;
        }
      }
    }
  }

  .f4 {
    margin: 10px 0;

    .f4-title {
      @extend .title
    }

    .f4_list_one {
      line-height: 40px;
      font-size: 18px;
    }

    .f4_list_two {
      height: 40px;
      background: #f2f2f2;
      border-radius: 10px;
      font-size: 14px;
      display: flex;
      align-items: center;
      justify-content: space-around;
    }
  }

  .f5 {
    width: 100%;

    .f5-title {
      display: flex;
      justify-content: space-between;
      margin: 20px 0;

      span:nth-child(1) {
        font-size: 18px;
      }

      span:nth-child(2) {
        font-size: 14px;
        color: #b7b7b7;
      }
    }

    .f5_list {
      ul {
        li {
          border-bottom: 1px solid #ccc;
          margin-bottom: 5px;

          .title {
            display: flex;
            align-items: center;
            justify-content: space-between;

            .username {
              font-size: 16px;
              margin: 10px;
            }

            .msg {
              color: #ccc;
              font-size: 13px;
            }

            .good {
              color: orange;
              font-size: 13px;
            }

            img {
              width: 30px;
              height: 30px;
              border-radius: 50%;
            }
          }

          .text {
            font-size: 16px;
            line-height: 30px;
            margin: 10px 0;
          }
        }
      }
    }
  }

  .f6 {
    display: flex;
    flex-direction: column;
    margin-top: 25px;

    .f6-top {
      padding: 10px;
      margin: 10px;
      border-radius: 5px;
      background: #f2f2f2;
      height: 40px;
      display: flex;
      align-items: center;
      justify-content: space-around;

      .f6_list {
        display: flex;
        flex: 1;
        justify-content: space-around;

        span {
          font-size: 12px;
          color: #31d363;
        }
      }
    }

    .f6-btm {
      padding: 10px;
      margin: 10px;
      margin-bottom: 10px;
      border-radius: 5px;
      font-size: 14px;
      text-align: center;
      background: #f2f2f2;
      line-height: 20px;

      span {
        color: #31d363;
      }
    }
  }

}
</style>
